package com.feihong.yw189.paidan.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.feihong.yw189.paidan.fragment.jiedan.AllList;
import com.feihong.yw189.paidan.fragment.jiedan.BaseList;
import com.feihong.yw189.paidan.fragment.jiedan.LiuDanList;
import com.feihong.yw189.paidan.fragment.jiedan.WaitList;
import com.feihong.yw189.paidan.inter.LiuDanListener;

import java.util.ArrayList;
import java.util.HashMap;

public class JieDanOrderAdapter extends FragmentPagerAdapter {

    private HashMap<String, String> numMap = new HashMap<>();
    public ArrayList<BaseList> fragments;

    public JieDanOrderAdapter(FragmentManager fm, LiuDanListener liuDanListener) {
        super(fm);
        fragments = new ArrayList<>();


        WaitList waitFragment = WaitList.newInstance(WaitList.class.getName());
        LiuDanList liudanFragment = LiuDanList.newInstance(LiuDanList.class.getName());
        AllList allFragment = AllList.newInstance(AllList.class.getName());

        waitFragment.setLiuDanListener(liuDanListener);
        liudanFragment.setLiuDanListener(liuDanListener);
        allFragment.setLiuDanListener(liuDanListener);

        fragments.add(waitFragment);
        fragments.add(liudanFragment);
        fragments.add(allFragment);

    }

    public void setData(HashMap<String, String> numMap) {
        this.numMap = numMap;
        notifyDataSetChanged();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return numMap.get("" + position);
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }
}
